﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script type="text/javascript">
        var nodeFrmID = "";
        $(function () {

            var html = "<table style='width:98%' >";
            html += "<tr>";
            html += "<th>序号</th>";
            html += "<th>类别</th>";
            html += "<th>表单ID</th>";
            html += "<th>名称</th>";
            html += "<th>存储表</th>";
            html += "<th>创建组织</th>";
            html += "<th>操作</th>";
            html += "</tr>";

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode_FrmSln");
            handler.AddPara("NodeID", GetQueryString("NodeID"));
            var data = handler.DoMethodReturnString("RefOneFrmTreeFrms_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);
            if (data.length == 0) {
                var html2 = "没有可供选择的表单。";
                $("#info").html(html2);
                return;
            }
            for (var i = 0; i < data.length; i++) {
                var en = data[i];

                if (en.No == 'Temp0')
                    continue;


                html += "<tr >";
                html += "<td>" + i + "</td>";
                html += "<td>" + en.SortName + "</td>";
                html += "<td>" + en.No + "</td>";
                html += "<td>" + en.Name + "</td>";
                html += "<td>" + en.PTable + "</td>";
                html += "<td>" + en.OrgName + "</td>";
                html += "<td><a href=\"javascript:Save('" + en.No + "')\">绑定</a></td>";
                html += "</tr>";
            }
            html += "</table>";
            $("#frms").html(html);
        });

        function Save(selectFrm) {

            if (window.confirm('您确定要绑定:' + selectFrm + "吗？") == false)
                return;

            //选择的表单.
            if (selectFrm == undefined || selectFrm == null) {
                alert('请选择一个表单');
                return;
            }

            var FK_Node = GetQueryString("NodeID");
            var node = new Entity("BP.WF.Node", FK_Node);
            node.NodeID = FK_Node;
            var i = node.RetrieveFromDBSources();

            //更新节点表单类型.
            node.FormType = FormSlnType.RefOneFrmTree;
            node.NodeFrmID = selectFrm; //选择的表单
            node.RefOneFrmTreeType = $("#DDL_FrmTree").val();

            var update = node.Update(); //执行更新.

            //节点表单属性
            var frmNode = new Entity("BP.WF.Template.FrmNode");
            frmNode.Delete("FK_Node", node.NodeID); //删除已经存在的表单.

            frmNode.MyPK = selectFrm + "_" + node.NodeID + "_" + node.FK_Flow;
            var i = frmNode.RetrieveFromDBSources();
            frmNode.FK_Node = node.NodeID;
            frmNode.FK_Flow = node.FK_Flow;
            frmNode.FK_Frm = selectFrm;
            frmNode.Save(); //执行保存.

            var html = "<a href=\"javascript:EditFrmNode('" + frmNode.MyPK + "')\" >编辑关联的表单属性</a> - <a href=\"javascript:SetAllNodeFrmUseThisSln()\">设置该流程所有的节点都采用此表单方案</a>";
            $("#Div_RefOneFrmTree").html(html);
            alert("独立表单库表单 - 保存成功.");
            parent.location.reload();
            parent.doCloseDialog.call();

            // parent.$("#MyFrm").html(frmNode.FK_Frm + ":" +selectName );
            // $(".panel-tool-close").click();

            return;
        }

    </script>
</head>
<body>
    <div id="table">
        <div id="frms"></div>
        <div id="info"></div>
    </div>
</body>
</html>
